<?php
/*
*All rights reserved: Yao Quan Li.
*Links:http://www.liyaoquan.cn.
*Links:http://www.imarkchina.cn.
*Date:2014.
*/
session_start();
error_reporting(E_ALL ^ E_NOTICE);
@include __Root__.'/Public/Resources/Config.php';
@include __Root__.'/Index/Point/Index_Config_Action.php';
$url=dirname('http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]);
$link = $Mark_Config_Action['root_link'];
$level = $Mark_Config_Action['level'];
$root_file = $Mark_Config_Action['root_file'];
$_SESSION['level'] = $Mark_Config_Action['level'];
if (isset($_SESSION['Mark_Login'])) {
	header("Location:".$url."/".$link."/index.php"); //重新定向到其他页面
    	exit();
}
if (isset($_POST['Post_Action'])) {
$administrator = $Mark_Config_Action['user_name'];
$password = $Mark_Config_Action['user_pass'];
if (isset($_SESSION['Mark_Login'])) { //判断SESSINON中是否有登陆
	 header("Location:".$level."/".$link."/index.php"); //重新定向到其他页面
    exit;
}
$root = $_POST['username'];
$pass = MD5($_POST['password']);
if ($root== '') { //判断POST来的用户名是否为空
    echo "<script language=javascript>alert('Please,Check Your Password!');window.location='".$level."/".$root_file."'</script>";
} elseif ($pass == '') { //判断POST来的密码名是否为空
   	echo "<script language=javascript>alert('Please,Check Your Password!');window.location='".$level."/".$root_file."'</script>";
} else { //两者不为空是判断用户名与密码是否正确
    if ($root == $administrator && $password == $pass) {
        $_SESSION["Mark_Login"] = "Mark_Login"; //注册新的变量,保存当前会话的昵称
         header("Location:".$level."/".$link."/index.php");  //登录成功重定向到管理页面
        
    } else {
    	echo "<script language=javascript>alert('Please,Check Your Password!');window.location='".$level."/".$root_file."'</script>";
    }
}
}
?> 
<!DOCTYPE html>
<!--[if lt IE 7 ]>
<html lang="en" class="ie6 ielt7 ielt8 ielt9">
<![endif]--><!--[if IE 7 ]>
<html lang="en" class="ie7 ielt8 ielt9">
<![endif]--><!--[if IE 8 ]>
<html lang="en" class="ie8 ielt9">
<![endif]--><!--[if IE 9 ]>
<html lang="en" class="ie9">
<![endif]--><!--[if (gt IE 9)|!(IE)]><!-->
<html lang="en">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<title><?php echo $Mark_Config_Action['site_name']; ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="<?php __ROOT__('Css/bootstrap.min.css'); ?>" rel="stylesheet">
<link href="<?php __ROOT__('Css/site.css'); ?>" rel="stylesheet">
<!--[if lt IE 9]>
<script src="<?php __ROOT__('Js/html5.js'); ?>"></script>
<![endif]-->
</head>
<body>
<div id="login-page" class="container">
	<h1>System Login</h1>
	<form id="login-form" class="well" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
	<input type="hidden" name="Post_Action" value=""/>
		<input type="text" class="span2" name="username" placeholder="Username"/><br/>
		<input type="password" class="span2" name="password" placeholder="Password"/><br/>
		<button type="submit" class="btn btn-primary">Action</button>
	</form>
	<div id="goback">
		<span id="back"><a href="<?php echo $url; ?>">←前台</a></span>
	<br/><br/>
	<font color="#000">© CopyRight 2014<?php Year(); ?></font> | <a href="http://www.creativecommons.org/licenses/by-nc-nd/3.0/cn/legalcode" target="_blank">署名-非商业性使用-禁止演绎 3.0</a></div>
</div>
</body>
</html>